package com.piepesken.mediscale.repository

import com.piepesken.mediscale.data.RoomDataSource
import com.piepesken.mediscale.models.Drug
import com.piepesken.mediscale.models.DrugDao
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

interface DrugRepository {
    fun getAllDrugs(): Flow<List<Drug>>
    fun getDrugById(id: Int): Flow<Drug>
    fun filterDrugsByText(text: String): Flow<List<Drug>>
}

class DrugRepositoryImp @Inject constructor(
    private val dataSource: RoomDataSource,
    private val drugDao: DrugDao
) : DrugRepository {
    override fun getAllDrugs() = drugDao.getDrugs()
    override fun getDrugById(id: Int) = drugDao.getDrugById(id)
    override fun filterDrugsByText(text: String): Flow<List<Drug>> = drugDao.getDrugWithContent(text)
}